// ------------------------------------遍历对象的方法---------------------------------
function iterator(self, keys) {
    return this.index < keys.length ? {
        value: self[keys[this.index++]],
        done: false
    } : {
        done: true
    }
}
Object.prototype[Symbol.iterator] = function() {
        let keys = Reflect.ownKeys(this);
        let self = this;
        let iter = {
            next: null,
            index: 0
        }
        iter.next = iterator.bind(iter, self, keys);
        return iter;
    }
    // ------------------------------------遍历对象的方法---------------------------------
    // ------------------------写在数组原型上的去重方法-------------------------------
Array.prototype.arrFilter = function() {
        let hashFilter = new Object();
        let arr = new Array();
        for (let i = 0; i < this.length; i++) {
            if (hashFilter[this[i]]) continue;
            hashFilter[this[i]] = 1;
            arr = [...arr, this[i]];
        }
        return arr;
    }
    // ------------------------写在数组原型上的去重方法-------------------------------
    // ---------------------------使用对象hash去重方法---------------------------------
function arrFilter(arr) {
    let newArr = new Array();
    let value = null;
    let hashMap = new Object();
    try {
        for (value of arr) {
            if (hashMap[value]) continue;
            hashMap[value] = 1;
            newArr = [...newArr, value];
        }
    } catch (err) {
        console.error(err.message);
    } finally {
        return newArr;
    }
}
// ---------------------------使用对象hash去重方法---------------------------------
//----------------------------使用Set对象去重的方法-------------------------
function filterBySet(arr) {
    return [...new Set(arr)];
}
//----------------------------使用Set对象去重的方法------------------------
//----------------------------使用reduce方法去重的方法-------------------
function myReduce(arr) {
    return arr.reduce((res, cur) => {
        if (!res.includes(cur)) {
            res.push(cur);
        }
        return res;
    }, []);
}
//----------------------------使用reduce方法去重的方法-------------------